package Jcat.cduestcbbs.Servlet;

import java.util.List;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Jcat.cduestcbbs.Po.PostsPo;
import Jcat.cduestcbbs.Po.ReplyPo;
import Jcat.cduestcbbs.Service.OnlyLookWritersService;

public class OnlyLookWritersServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
	private OnlyLookWritersService lookwriterspost = new OnlyLookWritersService();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		getWritersPostAndReply(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		getWritersPostAndReply(request,response);
	}
	
	public void getWritersPostAndReply(HttpServletRequest request, HttpServletResponse response)
	        throws ServletException, IOException {
		
		PostsPo post = (PostsPo) request.getSession().getAttribute("postwriter");
		request.setAttribute("post", post);
		
		List<ReplyPo> list = lookwriterspost.getWritersPostAndReply(post);
		request.setAttribute("allreplyslist", list);
		
		request.getRequestDispatcher("Pages_jsp/details.jsp").forward(request, response);
		
	}
}
